SET  ARITHABORT, NUMERIC_ROUNDABORT, CONCAT_NULL_YIELDS_NULL, ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, QUOTED_IDENTIFIER OFF
GO
:setvar DatabaseName "Oxite.Database"
:setvar PrimaryFilePhysicalName "C:\Program Files (x86)\Microsoft SQL Server\MSSQL.2\MSSQL\DATA\Oxite.Database.mdf"
:setvar PrimaryLogFilePhysicalName "C:\Program Files (x86)\Microsoft SQL Server\MSSQL.2\MSSQL\DATA\Oxite.Database_log.ldf"

USE [master]

GO

:on error exit

IF  (DB_ID(N'$(DatabaseName)') IS NOT NULL
    AND DATABASEPROPERTYEX(N'$(DatabaseName)','Status') <> N'ONLINE')
BEGIN
    RAISERROR(N'目标数据库 %s 的状态未设置为 ONLINE。要部署此数据库，数据库状态必须设置为 ONLINE。', 16, 127,N'$(DatabaseName)') WITH NOWAIT
    RETURN
END
GO

IF (DB_ID(N'$(DatabaseName)') IS NOT NULL)
BEGIN
    IF ((SELECT CAST(value AS nvarchar(128))
	    FROM 
		    [$(DatabaseName)]..fn_listextendedproperty('microsoft_database_tools_deploystamp', null, null, null, null, null, null )) 
	    = CAST(N'13474e0c-0e45-476c-a5e6-38e0f8b35de2' AS nvarchar(128)))
    BEGIN
	    RAISERROR(N'由于脚本已经部署到目标服务器，因此跳过了部署。', 16 ,100) WITH NOWAIT
	    RETURN
    END
END
GO


:on error exit

CREATE DATABASE [$(DatabaseName)] ON ( NAME = N'PrimaryFileName', FILENAME = N'$(PrimaryFilePhysicalName)') LOG ON ( NAME = N'PrimaryLogFileName', FILENAME = N'$(PrimaryLogFilePhysicalName)') COLLATE SQL_Latin1_General_CP1_CI_AS 

GO

:on error resume
     
EXEC sp_dbcmptlevel N'$(DatabaseName)', 90

GO

IF EXISTS (SELECT 1 FROM [sys].[databases] WHERE [name] = N'$(DatabaseName)') 
    ALTER DATABASE [$(DatabaseName)] SET  
	ALLOW_SNAPSHOT_ISOLATION OFF
GO

IF EXISTS (SELECT 1 FROM [sys].[databases] WHERE [name] = N'$(DatabaseName)') 
    ALTER DATABASE [$(DatabaseName)] SET  
	READ_COMMITTED_SNAPSHOT OFF
GO

IF EXISTS (SELECT 1 FROM [sys].[databases] WHERE [name] = N'$(DatabaseName)') 
    ALTER DATABASE [$(DatabaseName)] SET  
	MULTI_USER,
	CURSOR_CLOSE_ON_COMMIT OFF,
	CURSOR_DEFAULT LOCAL,
	AUTO_CLOSE OFF,
	AUTO_CREATE_STATISTICS ON,
	AUTO_SHRINK OFF,
	AUTO_UPDATE_STATISTICS ON,
	AUTO_UPDATE_STATISTICS_ASYNC ON,
	ANSI_NULL_DEFAULT ON,
	ANSI_NULLS OFF,
	ANSI_PADDING OFF,
	ANSI_WARNINGS OFF,
	ARITHABORT OFF,
	CONCAT_NULL_YIELDS_NULL OFF,
	NUMERIC_ROUNDABORT OFF,
	QUOTED_IDENTIFIER OFF,
	RECURSIVE_TRIGGERS OFF,
	RECOVERY FULL,
	PAGE_VERIFY NONE,
	DISABLE_BROKER,
	PARAMETERIZATION SIMPLE
	WITH ROLLBACK IMMEDIATE
GO

IF IS_SRVROLEMEMBER ('sysadmin') = 1
BEGIN

IF EXISTS (SELECT 1 FROM [sys].[databases] WHERE [name] = N'$(DatabaseName)') 
    EXEC sp_executesql N'
    ALTER DATABASE [$(DatabaseName)] SET  
	DB_CHAINING OFF,
	TRUSTWORTHY OFF'

END
ELSE
BEGIN
    RAISERROR(N'无法为 DB_CHAINING 或 TRUSTWORTHY 修改数据库设置。您必须是 SysAdmin 才能应用这些设置。',0,1)
END

GO

USE [$(DatabaseName)]

GO
/*
 Pre-Deployment Script Template							
--------------------------------------------------------------------------------------
 This file contains SQL statements that will be executed before the build script	
 Use SQLCMD syntax to include a file into the pre-deployment script			
 Example:      :r .\filename.sql								
 Use SQLCMD syntax to reference a variable in the pre-deployment script		
 Example:      :setvar TableName MyTable							
               SELECT * FROM [$(TableName)]					
--------------------------------------------------------------------------------------
*/








GO

:on error exit

:on error resume
GO
PRINT N'正在创建 [dbo].[oxite_Role]'
GO
CREATE TABLE [dbo].[oxite_Role]
(
[GroupRoleID] [uniqueidentifier] NOT NULL,
[RoleID] [uniqueidentifier] NOT NULL,
[RoleName] [nvarchar] (256) NOT NULL,
[RoleType] [tinyint] NOT NULL
) ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_Role] 上创建主键 [PK_oxite_Role]'
GO
ALTER TABLE [dbo].[oxite_Role] ADD CONSTRAINT [PK_oxite_Role] PRIMARY KEY CLUSTERED  ([RoleID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_SiteRoleUserRelationship]'
GO
CREATE TABLE [dbo].[oxite_SiteRoleUserRelationship]
(
[SiteID] [uniqueidentifier] NOT NULL,
[RoleID] [uniqueidentifier] NOT NULL,
[UserID] [uniqueidentifier] NOT NULL
) ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_SiteRoleUserRelationship] 上创建主键 [PK_oxite_SiteRoleUserRelationship]'
GO
ALTER TABLE [dbo].[oxite_SiteRoleUserRelationship] ADD CONSTRAINT [PK_oxite_SiteRoleUserRelationship] PRIMARY KEY CLUSTERED  ([SiteID], [RoleID], [UserID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_Blogs_Blog]'
GO
CREATE TABLE [dbo].[oxite_Blogs_Blog]
(
[SiteID] [uniqueidentifier] NOT NULL,
[BlogID] [uniqueidentifier] NOT NULL,
[BlogName] [nvarchar] (256) NOT NULL,
[DisplayName] [nvarchar] (256) NOT NULL,
[Description] [nvarchar] (256) NOT NULL,
[CommentingDisabled] [bit] NOT NULL CONSTRAINT [DF_oxite_Blogs_Blog_CommentingDisabled] DEFAULT ((0)),
[CreatedDate] [datetime] NOT NULL,
[ModifiedDate] [datetime] NOT NULL
) ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_Blogs_Blog] 上创建主键 [PK_oxite_Blogs_Blog]'
GO
ALTER TABLE [dbo].[oxite_Blogs_Blog] ADD CONSTRAINT [PK_oxite_Blogs_Blog] PRIMARY KEY CLUSTERED  ([BlogID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_Blogs_Trackback]'
GO
CREATE TABLE [dbo].[oxite_Blogs_Trackback]
(
[PostID] [uniqueidentifier] NOT NULL,
[TrackbackID] [uniqueidentifier] NOT NULL CONSTRAINT [DF_oxite_Blogs_Trackback_TrackbackID] DEFAULT (newid()),
[Url] [nvarchar] (1000) NOT NULL,
[Title] [nvarchar] (200) NOT NULL,
[Body] [nvarchar] (500) NOT NULL,
[Source] [nvarchar] (500) NOT NULL,
[BlogName] [nvarchar] (200) NOT NULL,
[IsTargetInSource] [bit] NULL,
[CreatedDate] [datetime] NOT NULL,
[ModifiedDate] [datetime] NOT NULL
) ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_Blogs_Trackback] 上创建主键 [PK_oxite_Blogs_Trackback]'
GO
ALTER TABLE [dbo].[oxite_Blogs_Trackback] ADD CONSTRAINT [PK_oxite_Blogs_Trackback] PRIMARY KEY CLUSTERED  ([TrackbackID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_CMS_ContentItem]'
GO
CREATE TABLE [dbo].[oxite_CMS_ContentItem]
(
[SiteID] [uniqueidentifier] NOT NULL,
[PageID] [uniqueidentifier] NULL,
[ContentItemID] [uniqueidentifier] NOT NULL,
[ContentItemName] [varchar] (50) NOT NULL,
[ContentItemDisplayName] [nvarchar] (200) NOT NULL,
[Body] [nvarchar] (max) NOT NULL,
[Version] [smallint] NOT NULL,
[CreatorUserID] [uniqueidentifier] NOT NULL,
[CreatedDate] [datetime] NOT NULL,
[PublishedDate] [datetime] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_CMS_ContentItem] 上创建主键 [PK_oxite_CMS_ContentItem]'
GO
ALTER TABLE [dbo].[oxite_CMS_ContentItem] ADD CONSTRAINT [PK_oxite_CMS_ContentItem] PRIMARY KEY CLUSTERED  ([ContentItemID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_Conferences_Event]'
GO
CREATE TABLE [dbo].[oxite_Conferences_Event]
(
[EventID] [uniqueidentifier] NOT NULL,
[EventName] [varchar] (50) NOT NULL,
[EventDisplayName] [nvarchar] (100) NOT NULL,
[Year] [smallint] NOT NULL
) ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_Conferences_Event] 上创建主键 [PK_oxite_Conferences_Event]'
GO
ALTER TABLE [dbo].[oxite_Conferences_Event] ADD CONSTRAINT [PK_oxite_Conferences_Event] PRIMARY KEY CLUSTERED  ([EventID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_Conferences_ScheduleItem]'
GO
CREATE TABLE [dbo].[oxite_Conferences_ScheduleItem]
(
[EventID] [uniqueidentifier] NOT NULL,
[ScheduleItemID] [uniqueidentifier] NOT NULL,
[Title] [nvarchar] (250) NOT NULL,
[Body] [nvarchar] (max) NOT NULL,
[Location] [nvarchar] (50) NOT NULL,
[Type] [nvarchar] (50) NOT NULL,
[Code] [nvarchar] (10) NOT NULL,
[StartTime] [datetime] NOT NULL,
[EndTime] [datetime] NOT NULL,
[Slug] [varchar] (250) NOT NULL,
[CreatedDate] [datetime] NOT NULL,
[ModifiedDate] [datetime] NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_Conferences_ScheduleItem] 上创建主键 [PK_oxite_Conferences_ScheduleItem]'
GO
ALTER TABLE [dbo].[oxite_Conferences_ScheduleItem] ADD CONSTRAINT [PK_oxite_Conferences_ScheduleItem] PRIMARY KEY CLUSTERED  ([ScheduleItemID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_Blogs_PostRoleUserRelationship]'
GO
CREATE TABLE [dbo].[oxite_Blogs_PostRoleUserRelationship]
(
[PostID] [uniqueidentifier] NOT NULL,
[RoleID] [uniqueidentifier] NOT NULL,
[UserID] [uniqueidentifier] NOT NULL
) ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_Blogs_PostRoleUserRelationship] 上创建主键 [PK_oxite_Blogs_PostRoleUserRelationship]'
GO
ALTER TABLE [dbo].[oxite_Blogs_PostRoleUserRelationship] ADD CONSTRAINT [PK_oxite_Blogs_PostRoleUserRelationship] PRIMARY KEY CLUSTERED  ([PostID], [RoleID], [UserID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_Blogs_PostFileRelationship]'
GO
CREATE TABLE [dbo].[oxite_Blogs_PostFileRelationship]
(
[PostID] [uniqueidentifier] NOT NULL,
[FileID] [uniqueidentifier] NOT NULL
) ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_Blogs_PostFileRelationship] 上创建主键 [PK_oxite_Blogs_PostFileRelationship]'
GO
ALTER TABLE [dbo].[oxite_Blogs_PostFileRelationship] ADD CONSTRAINT [PK_oxite_Blogs_PostFileRelationship] PRIMARY KEY CLUSTERED  ([PostID], [FileID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_Blogs_PostView]'
GO
CREATE TABLE [dbo].[oxite_Blogs_PostView]
(
[PostID] [uniqueidentifier] NOT NULL,
[PostViewTypeID] [uniqueidentifier] NOT NULL,
[PostViewID] [uniqueidentifier] NOT NULL,
[PostViewCount] [int] NOT NULL,
[PostViewDate] [datetime] NOT NULL
) ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_Blogs_PostView] 上创建主键 [PK_oxite_Blogs_PostView]'
GO
ALTER TABLE [dbo].[oxite_Blogs_PostView] ADD CONSTRAINT [PK_oxite_Blogs_PostView] PRIMARY KEY CLUSTERED  ([PostViewID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_Blogs_PostView] 的索引 [IX_oxite_Blogs_PostView_PostID]'
GO
CREATE NONCLUSTERED INDEX [IX_oxite_Blogs_PostView_PostID] ON [dbo].[oxite_Blogs_PostView] ([PostID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_Blogs_PostView] 的索引 [IX_oxite_Blogs_PostView_PostViewTypeID]'
GO
CREATE NONCLUSTERED INDEX [IX_oxite_Blogs_PostView_PostViewTypeID] ON [dbo].[oxite_Blogs_PostView] ([PostViewTypeID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_CMS_PageRoleUserRelationship]'
GO
CREATE TABLE [dbo].[oxite_CMS_PageRoleUserRelationship]
(
[PageID] [uniqueidentifier] NOT NULL,
[RoleID] [uniqueidentifier] NOT NULL,
[UserID] [uniqueidentifier] NOT NULL
) ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_CMS_PageRoleUserRelationship] 上创建主键 [PK_oxite_CMS_PageRoleUserRelationship]'
GO
ALTER TABLE [dbo].[oxite_CMS_PageRoleUserRelationship] ADD CONSTRAINT [PK_oxite_CMS_PageRoleUserRelationship] PRIMARY KEY CLUSTERED  ([PageID], [RoleID], [UserID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_Blogs_BlogRoleUserRelationship]'
GO
CREATE TABLE [dbo].[oxite_Blogs_BlogRoleUserRelationship]
(
[BlogID] [uniqueidentifier] NOT NULL,
[RoleID] [uniqueidentifier] NOT NULL,
[UserID] [uniqueidentifier] NOT NULL
) ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_Blogs_BlogRoleUserRelationship] 上创建主键 [PK_oxite_Blogs_BlogRoleUserRelationship]'
GO
ALTER TABLE [dbo].[oxite_Blogs_BlogRoleUserRelationship] ADD CONSTRAINT [PK_oxite_Blogs_BlogRoleUserRelationship] PRIMARY KEY CLUSTERED  ([BlogID], [RoleID], [UserID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_Conferences_ScheduleItemUserRelationship]'
GO
CREATE TABLE [dbo].[oxite_Conferences_ScheduleItemUserRelationship]
(
[ScheduleItemID] [uniqueidentifier] NOT NULL,
[UserID] [uniqueidentifier] NOT NULL
) ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_Conferences_ScheduleItemUserRelationship] 上创建主键 [PK_oxite_Conferences_ScheduleItemUserRelationship]'
GO
ALTER TABLE [dbo].[oxite_Conferences_ScheduleItemUserRelationship] ADD CONSTRAINT [PK_oxite_Conferences_ScheduleItemUserRelationship] PRIMARY KEY CLUSTERED  ([ScheduleItemID], [UserID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_Conferences_ScheduleItemSubscriptionRelationship]'
GO
CREATE TABLE [dbo].[oxite_Conferences_ScheduleItemSubscriptionRelationship]
(
[ScheduleItemID] [uniqueidentifier] NOT NULL,
[SubscriptionID] [uniqueidentifier] NOT NULL
) ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_Conferences_ScheduleItemSubscriptionRelationship] 上创建主键 [PK_oxite_Conferences_ScheduleItemSubscriptionRelationship]'
GO
ALTER TABLE [dbo].[oxite_Conferences_ScheduleItemSubscriptionRelationship] ADD CONSTRAINT [PK_oxite_Conferences_ScheduleItemSubscriptionRelationship] PRIMARY KEY CLUSTERED  ([ScheduleItemID], [SubscriptionID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_Language]'
GO
CREATE TABLE [dbo].[oxite_Language]
(
[LanguageID] [uniqueidentifier] NOT NULL,
[LanguageName] [varchar] (8) NOT NULL,
[LanguageDisplayName] [nvarchar] (50) NOT NULL
) ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_Language] 上创建主键 [PK_oxite_Language]'
GO
ALTER TABLE [dbo].[oxite_Language] ADD CONSTRAINT [PK_oxite_Language] PRIMARY KEY CLUSTERED  ([LanguageID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_UserLanguage]'
GO
CREATE TABLE [dbo].[oxite_UserLanguage]
(
[UserID] [uniqueidentifier] NOT NULL,
[LanguageID] [uniqueidentifier] NOT NULL
) ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_UserLanguage] 上创建主键 [PK_oxite_UserLanguage]'
GO
ALTER TABLE [dbo].[oxite_UserLanguage] ADD CONSTRAINT [PK_oxite_UserLanguage] PRIMARY KEY CLUSTERED  ([UserID], [LanguageID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_Conferences_ScheduleTimeSlot]'
GO
CREATE TABLE [dbo].[oxite_Conferences_ScheduleTimeSlot]
(
[EventID] [uniqueidentifier] NOT NULL,
[ScheduleTimeSlotID] [uniqueidentifier] NOT NULL,
[StartTime] [datetime] NOT NULL,
[EndTime] [datetime] NOT NULL,
[Description] [nvarchar] (250) NOT NULL
) ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_Conferences_ScheduleTimeSlot] 上创建主键 [PK_oxite_Conferences_ScheduleTimeSlot]'
GO
ALTER TABLE [dbo].[oxite_Conferences_ScheduleTimeSlot] ADD CONSTRAINT [PK_oxite_Conferences_ScheduleTimeSlot] PRIMARY KEY CLUSTERED  ([ScheduleTimeSlotID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_Conferences_ScheduleItemFlag]'
GO
CREATE TABLE [dbo].[oxite_Conferences_ScheduleItemFlag]
(
[ScheduleItemID] [uniqueidentifier] NOT NULL,
[FlagType] [nvarchar] (50) NOT NULL
) ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_Conferences_ScheduleItemFlag] 上创建主键 [PK_oxite_Conferences_ScheduleItemFlag]'
GO
ALTER TABLE [dbo].[oxite_Conferences_ScheduleItemFlag] ADD CONSTRAINT [PK_oxite_Conferences_ScheduleItemFlag] PRIMARY KEY CLUSTERED  ([ScheduleItemID], [FlagType]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_Plugin]'
GO
CREATE TABLE [dbo].[oxite_Plugin]
(
[SiteID] [uniqueidentifier] NOT NULL,
[PluginID] [uniqueidentifier] NOT NULL,
[VirtualPath] [nvarchar] (4000) NOT NULL,
[Enabled] [bit] NOT NULL
) ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_Plugin] 上创建主键 [PK_oxite_Plugin]'
GO
ALTER TABLE [dbo].[oxite_Plugin] ADD CONSTRAINT [PK_oxite_Plugin] PRIMARY KEY CLUSTERED  ([PluginID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_Subscription]'
GO
CREATE TABLE [dbo].[oxite_Subscription]
(
[SubscriptionID] [uniqueidentifier] NOT NULL,
[UserID] [uniqueidentifier] NOT NULL,
[UserName] [nvarchar] (50) NULL,
[UserEmail] [nvarchar] (100) NULL
) ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_Subscription] 上创建主键 [PK_oxite_Subscription]'
GO
ALTER TABLE [dbo].[oxite_Subscription] ADD CONSTRAINT [PK_oxite_Subscription] PRIMARY KEY CLUSTERED  ([SubscriptionID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_Blogs_PostSubscriptionRelationship]'
GO
CREATE TABLE [dbo].[oxite_Blogs_PostSubscriptionRelationship]
(
[PostID] [uniqueidentifier] NOT NULL,
[SubscriptionID] [uniqueidentifier] NOT NULL
) ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_Blogs_PostSubscriptionRelationship] 上创建主键 [PK_oxite_Blogs_PostSubscriptionRelationship]'
GO
ALTER TABLE [dbo].[oxite_Blogs_PostSubscriptionRelationship] ADD CONSTRAINT [PK_oxite_Blogs_PostSubscriptionRelationship] PRIMARY KEY CLUSTERED  ([PostID], [SubscriptionID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_Blogs_PostViewType]'
GO
CREATE TABLE [dbo].[oxite_Blogs_PostViewType]
(
[PostViewTypeID] [uniqueidentifier] NOT NULL,
[PostViewTypeName] [nvarchar] (25) NOT NULL
) ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_Blogs_PostViewType] 上创建主键 [PK_oxite_Blogs_PostViewType]'
GO
ALTER TABLE [dbo].[oxite_Blogs_PostViewType] ADD CONSTRAINT [PK_oxite_Blogs_PostViewType] PRIMARY KEY CLUSTERED  ([PostViewTypeID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_Blogs_PostCommentRelationship]'
GO
CREATE TABLE [dbo].[oxite_Blogs_PostCommentRelationship]
(
[PostID] [uniqueidentifier] NOT NULL,
[CommentID] [uniqueidentifier] NOT NULL,
[Slug] [char] (5) NOT NULL
) ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_Blogs_PostCommentRelationship] 上创建主键 [PK_oxite_Blogs_PostCommentRelationship]'
GO
ALTER TABLE [dbo].[oxite_Blogs_PostCommentRelationship] ADD CONSTRAINT [PK_oxite_Blogs_PostCommentRelationship] PRIMARY KEY CLUSTERED  ([PostID], [CommentID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_Blogs_PostTagRelationship]'
GO
CREATE TABLE [dbo].[oxite_Blogs_PostTagRelationship]
(
[PostID] [uniqueidentifier] NOT NULL,
[TagID] [uniqueidentifier] NOT NULL,
[TagDisplayName] [nvarchar] (max) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_Blogs_PostTagRelationship] 上创建主键 [PK_oxite_Blogs_PostTagRelationship]'
GO
ALTER TABLE [dbo].[oxite_Blogs_PostTagRelationship] ADD CONSTRAINT [PK_oxite_Blogs_PostTagRelationship] PRIMARY KEY CLUSTERED  ([PostID], [TagID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_ExtendedProperty]'
GO
CREATE TABLE [dbo].[oxite_ExtendedProperty]
(
[ExtendedPropertyID] [uniqueidentifier] NOT NULL,
[ExtendedPropertyName] [nvarchar] (50) NOT NULL
) ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_ExtendedProperty] 上创建主键 [PK_oxite_ExtendedProperty]'
GO
ALTER TABLE [dbo].[oxite_ExtendedProperty] ADD CONSTRAINT [PK_oxite_ExtendedProperty] PRIMARY KEY CLUSTERED  ([ExtendedPropertyID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_ExtendedPropertyValue]'
GO
CREATE TABLE [dbo].[oxite_ExtendedPropertyValue]
(
[SiteID] [uniqueidentifier] NOT NULL,
[ExtendedPropertyID] [uniqueidentifier] NOT NULL,
[ExtendedPropertyType] [nvarchar] (500) NOT NULL,
[ExtendedPropertyValue] [xml] NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_ExtendedPropertyValue] 上创建主键 [PK_oxite_ExtendedPropertyValue]'
GO
ALTER TABLE [dbo].[oxite_ExtendedPropertyValue] ADD CONSTRAINT [PK_oxite_ExtendedPropertyValue] PRIMARY KEY CLUSTERED  ([SiteID], [ExtendedPropertyID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_Comment]'
GO
CREATE TABLE [dbo].[oxite_Comment]
(
[ParentCommentID] [uniqueidentifier] NOT NULL,
[CommentID] [uniqueidentifier] NOT NULL,
[CreatorUserID] [uniqueidentifier] NOT NULL,
[CreatorName] [nvarchar] (50) NULL,
[CreatorEmail] [nvarchar] (100) NULL,
[CreatorHashedEmail] [nvarchar] (200) NULL,
[CreatorUrl] [nvarchar] (300) NULL,
[LanguageID] [uniqueidentifier] NOT NULL,
[CreatorIP] [bigint] NOT NULL,
[UserAgent] [nvarchar] (max) NOT NULL,
[Body] [nvarchar] (max) NOT NULL,
[State] [tinyint] NOT NULL,
[CreatedDate] [datetime] NOT NULL,
[ModifiedDate] [datetime] NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_Comment] 上创建主键 [PK_oxite_Comment]'
GO
ALTER TABLE [dbo].[oxite_Comment] ADD CONSTRAINT [PK_oxite_Comment] PRIMARY KEY CLUSTERED  ([CommentID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_Comment] 的索引 [IX_oxite_Comment_CreatedDate]'
GO
CREATE NONCLUSTERED INDEX [IX_oxite_Comment_CreatedDate] ON [dbo].[oxite_Comment] ([CreatedDate]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_CMS_Page]'
GO
CREATE TABLE [dbo].[oxite_CMS_Page]
(
[SiteID] [uniqueidentifier] NOT NULL,
[PageID] [uniqueidentifier] NOT NULL,
[TemplateName] [nvarchar] (50) NOT NULL,
[Title] [nvarchar] (50) NOT NULL,
[Description] [nvarchar] (max) NOT NULL,
[Slug] [varchar] (500) NOT NULL,
[PublishedDate] [datetime] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_CMS_Page] 上创建主键 [PK_oxite_CMS_Page]'
GO
ALTER TABLE [dbo].[oxite_CMS_Page] ADD CONSTRAINT [PK_oxite_CMS_Page] PRIMARY KEY CLUSTERED  ([PageID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_UserModuleData]'
GO
CREATE TABLE [dbo].[oxite_UserModuleData]
(
[UserID] [uniqueidentifier] NOT NULL,
[ModuleName] [nvarchar] (50) NOT NULL,
[Data] [nvarchar] (max) NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_UserModuleData] 上创建主键 [PK_oxite_UserModuleData]'
GO
ALTER TABLE [dbo].[oxite_UserModuleData] ADD CONSTRAINT [PK_oxite_UserModuleData] PRIMARY KEY CLUSTERED  ([UserID], [ModuleName]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_Conferences_ScheduleItemTagRelationship]'
GO
CREATE TABLE [dbo].[oxite_Conferences_ScheduleItemTagRelationship]
(
[ScheduleItemID] [uniqueidentifier] NOT NULL,
[TagID] [uniqueidentifier] NOT NULL,
[TagDisplayName] [nvarchar] (max) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_Conferences_ScheduleItemTagRelationship] 上创建主键 [PK_oxite_Conferences_ScheduleItemTagRelationship]'
GO
ALTER TABLE [dbo].[oxite_Conferences_ScheduleItemTagRelationship] ADD CONSTRAINT [PK_oxite_Conferences_ScheduleItemTagRelationship] PRIMARY KEY CLUSTERED  ([ScheduleItemID], [TagID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_Conferences_ScheduleItemFileRelationship]'
GO
CREATE TABLE [dbo].[oxite_Conferences_ScheduleItemFileRelationship]
(
[ScheduleItemID] [uniqueidentifier] NOT NULL,
[FileID] [uniqueidentifier] NOT NULL
) ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_Conferences_ScheduleItemFileRelationship] 上创建主键 [PK_oxite_Conferences_ScheduleItemFileRelationship]'
GO
ALTER TABLE [dbo].[oxite_Conferences_ScheduleItemFileRelationship] ADD CONSTRAINT [PK_oxite_Conferences_ScheduleItemFileRelationship] PRIMARY KEY CLUSTERED  ([ScheduleItemID], [FileID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_Conferences_Speaker]'
GO
CREATE TABLE [dbo].[oxite_Conferences_Speaker]
(
[SpeakerID] [uniqueidentifier] NOT NULL,
[SpeakerName] [varchar] (50) NOT NULL,
[SpeakerDisplayName] [nvarchar] (50) NOT NULL,
[Bio] [nvarchar] (max) NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_Conferences_Speaker] 上创建主键 [PK_oxite_Conferences_Speaker]'
GO
ALTER TABLE [dbo].[oxite_Conferences_Speaker] ADD CONSTRAINT [PK_oxite_Conferences_Speaker] PRIMARY KEY CLUSTERED  ([SpeakerID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_Conferences_ScheduleItemSpeakerRelationship]'
GO
CREATE TABLE [dbo].[oxite_Conferences_ScheduleItemSpeakerRelationship]
(
[ScheduleItemID] [uniqueidentifier] NOT NULL,
[SpeakerID] [uniqueidentifier] NOT NULL
) ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_Conferences_ScheduleItemSpeakerRelationship] 上创建主键 [PK_oxite_Conferences_ScheduleItemSpeakerRelationship]'
GO
ALTER TABLE [dbo].[oxite_Conferences_ScheduleItemSpeakerRelationship] ADD CONSTRAINT [PK_oxite_Conferences_ScheduleItemSpeakerRelationship] PRIMARY KEY CLUSTERED  ([ScheduleItemID], [SpeakerID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_StringResource]'
GO
CREATE TABLE [dbo].[oxite_StringResource]
(
[StringResourceKey] [nvarchar] (256) NOT NULL,
[Language] [varchar] (8) NOT NULL,
[Version] [smallint] NOT NULL,
[StringResourceValue] [nvarchar] (max) NOT NULL,
[CreatorUserID] [uniqueidentifier] NOT NULL,
[CreatedDate] [datetime] NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_StringResource] 上创建主键 [PK_oxite_StringResource]'
GO
ALTER TABLE [dbo].[oxite_StringResource] ADD CONSTRAINT [PK_oxite_StringResource] PRIMARY KEY CLUSTERED  ([StringResourceKey]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_StringResourceVersion]'
GO
CREATE TABLE [dbo].[oxite_StringResourceVersion]
(
[StringResourceKey] [nvarchar] (256) NOT NULL,
[Language] [varchar] (8) NOT NULL,
[Version] [smallint] NOT NULL,
[StringResourceValue] [nvarchar] (max) NOT NULL,
[CreatorUserID] [uniqueidentifier] NOT NULL,
[CreatedDate] [datetime] NOT NULL,
[State] [tinyint] NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_StringResourceVersion] 上创建主键 [PK_oxite_StringResourceVersion]'
GO
ALTER TABLE [dbo].[oxite_StringResourceVersion] ADD CONSTRAINT [PK_oxite_StringResourceVersion] PRIMARY KEY CLUSTERED  ([StringResourceKey], [Language], [Version]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_ExtendedPropertyScope]'
GO
CREATE TABLE [dbo].[oxite_ExtendedPropertyScope]
(
[ExtendedPropertyID] [uniqueidentifier] NOT NULL,
[ExtendedPropertyScopeType] [nvarchar] (100) NOT NULL,
[ExtendedPropertyScopeKey] [nvarchar] (200) NOT NULL
) ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_ExtendedPropertyScope] 上创建主键 [PK_oxite_ExtendedPropertyScope]'
GO
ALTER TABLE [dbo].[oxite_ExtendedPropertyScope] ADD CONSTRAINT [PK_oxite_ExtendedPropertyScope] PRIMARY KEY CLUSTERED  ([ExtendedPropertyID], [ExtendedPropertyScopeType], [ExtendedPropertyScopeKey]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_CMS_PageContentItemRelationship]'
GO
CREATE TABLE [dbo].[oxite_CMS_PageContentItemRelationship]
(
[PageID] [uniqueidentifier] NOT NULL,
[ContentItemID] [uniqueidentifier] NOT NULL
) ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_CMS_PageContentItemRelationship] 上创建主键 [PK_oxite_CMS_PageContentItemRelationship]'
GO
ALTER TABLE [dbo].[oxite_CMS_PageContentItemRelationship] ADD CONSTRAINT [PK_oxite_CMS_PageContentItemRelationship] PRIMARY KEY CLUSTERED  ([PageID], [ContentItemID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_SiteRedirect]'
GO
CREATE TABLE [dbo].[oxite_SiteRedirect]
(
[SiteID] [uniqueidentifier] NOT NULL,
[SiteRedirect] [varchar] (100) NOT NULL
) ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_SiteRedirect] 上创建主键 [PK_oxite_SiteRedirect]'
GO
ALTER TABLE [dbo].[oxite_SiteRedirect] ADD CONSTRAINT [PK_oxite_SiteRedirect] PRIMARY KEY CLUSTERED  ([SiteID], [SiteRedirect]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_Conferences_ScheduleItemCommentRelationship]'
GO
CREATE TABLE [dbo].[oxite_Conferences_ScheduleItemCommentRelationship]
(
[ScheduleItemID] [uniqueidentifier] NOT NULL,
[CommentID] [uniqueidentifier] NOT NULL,
[Slug] [char] (5) NOT NULL
) ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_Conferences_ScheduleItemCommentRelationship] 上创建主键 [PK_oxite_Conferences_ScheduleItemCommentRelationship]'
GO
ALTER TABLE [dbo].[oxite_Conferences_ScheduleItemCommentRelationship] ADD CONSTRAINT [PK_oxite_Conferences_ScheduleItemCommentRelationship] PRIMARY KEY CLUSTERED  ([ScheduleItemID], [CommentID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_PluginSequence]'
GO
CREATE TABLE [dbo].[oxite_PluginSequence]
(
[PluginID] [uniqueidentifier] NOT NULL,
[OperationType] [varchar] (50) NOT NULL,
[OperationName] [nvarchar] (100) NOT NULL,
[SequenceNumber] [tinyint] NOT NULL
) ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_PluginSequence] 上创建主键 [PK_oxite_PluginSequence]'
GO
ALTER TABLE [dbo].[oxite_PluginSequence] ADD CONSTRAINT [PK_oxite_PluginSequence] PRIMARY KEY CLUSTERED  ([PluginID], [OperationType], [OperationName], [SequenceNumber]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_User]'
GO
CREATE TABLE [dbo].[oxite_User]
(
[UserID] [uniqueidentifier] NOT NULL CONSTRAINT [DF_oxite_User_UserID] DEFAULT (newid()),
[Username] [nvarchar] (256) NOT NULL,
[DisplayName] [nvarchar] (256) NOT NULL,
[Email] [nvarchar] (256) NOT NULL,
[HashedEmail] [nvarchar] (100) NOT NULL,
[DefaultLanguageID] [uniqueidentifier] NOT NULL,
[Status] [tinyint] NOT NULL
) ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_User] 上创建主键 [PK_oxite_User]'
GO
ALTER TABLE [dbo].[oxite_User] ADD CONSTRAINT [PK_oxite_User] PRIMARY KEY CLUSTERED  ([UserID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_Blogs_Post]'
GO
CREATE TABLE [dbo].[oxite_Blogs_Post]
(
[BlogID] [uniqueidentifier] NOT NULL,
[PostID] [uniqueidentifier] NOT NULL CONSTRAINT [DF_oxite_Blogs_Post_PostID] DEFAULT (newid()),
[CreatorUserID] [uniqueidentifier] NOT NULL,
[Title] [nvarchar] (256) NOT NULL,
[Body] [nvarchar] (max) NOT NULL,
[BodyShort] [nvarchar] (max) NOT NULL,
[State] [tinyint] NOT NULL,
[Slug] [nvarchar] (256) NOT NULL,
[CommentingDisabled] [bit] NOT NULL CONSTRAINT [DF_oxite_Blogs_Post_CommentingDisabled] DEFAULT ((0)),
[CreatedDate] [datetime] NOT NULL,
[ModifiedDate] [datetime] NOT NULL,
[PublishedDate] [datetime] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_Blogs_Post] 上创建主键 [PK_oxite_Blogs_Post]'
GO
ALTER TABLE [dbo].[oxite_Blogs_Post] ADD CONSTRAINT [PK_oxite_Blogs_Post] PRIMARY KEY CLUSTERED  ([PostID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_Blogs_Post] 的索引 [IX_oxite_Blogs_Post_Slug_PostID]'
GO
CREATE UNIQUE NONCLUSTERED INDEX [IX_oxite_Blogs_Post_Slug_PostID] ON [dbo].[oxite_Blogs_Post] ([Slug], [PostID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_Blogs_Post] 的索引 [IX_oxite_Blogs_Post_PublishedDate]'
GO
CREATE NONCLUSTERED INDEX [IX_oxite_Blogs_Post_PublishedDate] ON [dbo].[oxite_Blogs_Post] ([PublishedDate] DESC) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_Site]'
GO
CREATE TABLE [dbo].[oxite_Site]
(
[SiteID] [uniqueidentifier] NOT NULL,
[SiteHost] [varchar] (100) NOT NULL,
[SiteName] [nvarchar] (50) NOT NULL,
[SiteDisplayName] [nvarchar] (50) NOT NULL,
[SiteDescription] [nvarchar] (250) NOT NULL,
[LanguageDefault] [varchar] (8) NOT NULL,
[TimeZoneOffset] [float] NOT NULL,
[PageTitleSeparator] [nvarchar] (10) NOT NULL,
[FavIconUrl] [varchar] (50) NOT NULL,
[CommentStateDefault] [varchar] (25) NOT NULL,
[IncludeOpenSearch] [bit] NOT NULL,
[AuthorAutoSubscribe] [bit] NOT NULL,
[PostEditTimeout] [smallint] NOT NULL,
[GravatarDefault] [varchar] (100) NOT NULL,
[SkinsPath] [varchar] (50) NOT NULL,
[SkinsScriptsPath] [varchar] (50) NOT NULL,
[SkinsStylesPath] [varchar] (50) NOT NULL,
[Skin] [varchar] (50) NOT NULL,
[AdminSkin] [varchar] (50) NOT NULL,
[ServiceRetryCountDefault] [tinyint] NOT NULL CONSTRAINT [DF_oxite_Site_ServiceRetryCountDefault] DEFAULT ((3)),
[HasMultipleBlogs] [bit] NOT NULL CONSTRAINT [DF_oxite_Site_HasMultipleBlogs] DEFAULT ((0)),
[RouteUrlPrefix] [varchar] (20) NOT NULL CONSTRAINT [DF_oxite_Site_RouteUrlPrefix] DEFAULT (N''),
[CommentingDisabled] [bit] NOT NULL,
[PluginsPath] [varchar] (50) NOT NULL
) ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_Site] 上创建主键 [PK_oxite_Site]'
GO
ALTER TABLE [dbo].[oxite_Site] ADD CONSTRAINT [PK_oxite_Site] PRIMARY KEY CLUSTERED  ([SiteID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_Site] 的索引 [IX_oxite_Site_SiteName]'
GO
CREATE UNIQUE NONCLUSTERED INDEX [IX_oxite_Site_SiteName] ON [dbo].[oxite_Site] ([SiteName]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_Tag]'
GO
CREATE TABLE [dbo].[oxite_Tag]
(
[ParentTagID] [uniqueidentifier] NOT NULL,
[TagID] [uniqueidentifier] NOT NULL CONSTRAINT [DF_oxite_Tag_TagID] DEFAULT (newid()),
[TagName] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL,
[CreatedDate] [datetime] NOT NULL
) ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_Tag] 上创建主键 [PK_oxite_Tag]'
GO
ALTER TABLE [dbo].[oxite_Tag] ADD CONSTRAINT [PK_oxite_Tag] PRIMARY KEY CLUSTERED  ([TagID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_File]'
GO
CREATE TABLE [dbo].[oxite_File]
(
[FileID] [uniqueidentifier] NOT NULL,
[TypeName] [nvarchar] (50) NOT NULL CONSTRAINT [DF_oxite_File_TypeName] DEFAULT (''),
[MimeType] [varchar] (100) NOT NULL,
[Url] [varchar] (max) NOT NULL,
[Length] [bigint] NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_File] 上创建主键 [PK_oxite_File]'
GO
ALTER TABLE [dbo].[oxite_File] ADD CONSTRAINT [PK_oxite_File] PRIMARY KEY CLUSTERED  ([FileID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_File] 的索引 [IX_oxite_File_TypeName]'
GO
CREATE NONCLUSTERED INDEX [IX_oxite_File_TypeName] ON [dbo].[oxite_File] ([TypeName]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_Conferences_UserSchedule]'
GO
CREATE TABLE [dbo].[oxite_Conferences_UserSchedule]
(
[UserID] [uniqueidentifier] NOT NULL,
[IsPublic] [bit] NOT NULL
) ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_Conferences_UserSchedule] 上创建主键 [PK_oxite_Conferences_UserSchedule]'
GO
ALTER TABLE [dbo].[oxite_Conferences_UserSchedule] ADD CONSTRAINT [PK_oxite_Conferences_UserSchedule] PRIMARY KEY CLUSTERED  ([UserID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_MessageOutbound]'
GO
CREATE TABLE [dbo].[oxite_MessageOutbound]
(
[MessageOutboundID] [uniqueidentifier] NOT NULL,
[MessageTo] [nvarchar] (max) NOT NULL,
[MessageSubject] [nvarchar] (250) NOT NULL,
[MessageBody] [nvarchar] (max) NOT NULL,
[IsSending] [bit] NOT NULL,
[RemainingRetryCount] [tinyint] NOT NULL,
[SentDate] [smalldatetime] NULL,
[LastAttemptDate] [smalldatetime] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_MessageOutbound] 上创建主键 [PK_oxite_MessageOutbound]'
GO
ALTER TABLE [dbo].[oxite_MessageOutbound] ADD CONSTRAINT [PK_oxite_MessageOutbound] PRIMARY KEY CLUSTERED  ([MessageOutboundID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_SearchResult]'
GO
CREATE TABLE [dbo].[oxite_SearchResult]
(
[SearchResultID] [uniqueidentifier] NOT NULL,
[SearchResultIndex] [nvarchar] (max) NOT NULL,
[Title] [nvarchar] (250) NOT NULL,
[Body] [nvarchar] (max) NOT NULL,
[Url] [varchar] (200) NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_SearchResult] 上创建主键 [PK_oxite_SearchResult]'
GO
ALTER TABLE [dbo].[oxite_SearchResult] ADD CONSTRAINT [PK_oxite_SearchResult] PRIMARY KEY CLUSTERED  ([SearchResultID]) ON [PRIMARY]
GO
PRINT N'正在创建 [dbo].[oxite_TrackbackOutbound]'
GO
CREATE TABLE [dbo].[oxite_TrackbackOutbound]
(
[TrackbackOutboundID] [uniqueidentifier] NOT NULL,
[TargetUrl] [varchar] (200) NOT NULL,
[PostID] [uniqueidentifier] NOT NULL,
[PostTitle] [nvarchar] (255) NOT NULL,
[PostBlogTitle] [nvarchar] (255) NOT NULL,
[PostBody] [nvarchar] (max) NOT NULL,
[PostUrl] [varchar] (200) NOT NULL,
[IsSending] [bit] NOT NULL,
[RemainingRetryCount] [tinyint] NOT NULL,
[SentDate] [smalldatetime] NULL,
[LastAttemptDate] [smalldatetime] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
PRINT N'正在 [dbo].[oxite_TrackbackOutbound] 上创建主键 [PK_oxite_TrackbackOutbound]'
GO
ALTER TABLE [dbo].[oxite_TrackbackOutbound] ADD CONSTRAINT [PK_oxite_TrackbackOutbound] PRIMARY KEY CLUSTERED  ([TrackbackOutboundID]) ON [PRIMARY]
GO
PRINT N'正在向 [dbo].[oxite_Role] 添加约束 '
GO
ALTER TABLE [dbo].[oxite_Role] ADD CONSTRAINT [IX_oxite_RoleName] UNIQUE NONCLUSTERED  ([RoleName]) ON [PRIMARY]
GO
PRINT N'正在向 [dbo].[oxite_CMS_ContentItem] 添加约束 '
GO
ALTER TABLE [dbo].[oxite_CMS_ContentItem] ADD CONSTRAINT [IX_oxite_CMS_ContentItem_ContentItemName_Version_PageID_SiteID] UNIQUE NONCLUSTERED  ([ContentItemName], [Version] DESC, [PageID], [SiteID]) ON [PRIMARY]
GO
PRINT N'正在向 [dbo].[oxite_Blogs_Blog] 添加约束 '
GO
ALTER TABLE [dbo].[oxite_Blogs_Blog] ADD CONSTRAINT [IX_oxite_Blogs_Blog_BlogName_SiteID] UNIQUE NONCLUSTERED  ([BlogName], [SiteID]) ON [PRIMARY]
GO
PRINT N'正在向 [dbo].[oxite_CMS_Page] 添加约束 '
GO
ALTER TABLE [dbo].[oxite_CMS_Page] ADD CONSTRAINT [IX_oxite_CMS_Page_Slug] UNIQUE NONCLUSTERED  ([Slug]) ON [PRIMARY]
GO
PRINT N'正在向 [dbo].[oxite_Blogs_PostViewType] 添加约束 '
GO
ALTER TABLE [dbo].[oxite_Blogs_PostViewType] ADD CONSTRAINT [IX_oxite_Blogs_PostViewType_PostViewTypeName] UNIQUE NONCLUSTERED  ([PostViewTypeName]) ON [PRIMARY]
GO
PRINT N'正在向 [dbo].[oxite_User] 添加约束 '
GO
ALTER TABLE [dbo].[oxite_User] ADD CONSTRAINT [IX_oxite_User_Username] UNIQUE NONCLUSTERED  ([Username]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[oxite_User] ADD CONSTRAINT [IX_oxite_Username] UNIQUE NONCLUSTERED  ([Username]) ON [PRIMARY]
GO
PRINT N'正在向 [dbo].[oxite_Blogs_PostCommentRelationship] 添加约束 '
GO
ALTER TABLE [dbo].[oxite_Blogs_PostCommentRelationship] ADD CONSTRAINT [IX_oxite_Blogs_PostCommentRelationship_Slug_PostID] UNIQUE NONCLUSTERED  ([Slug], [PostID]) ON [PRIMARY]
GO
PRINT N'正在向 [dbo].[oxite_Conferences_Speaker] 添加约束 '
GO
ALTER TABLE [dbo].[oxite_Conferences_Speaker] ADD CONSTRAINT [IX_oxite_Conferences_Speaker_SpeakerName] UNIQUE NONCLUSTERED  ([SpeakerName]) ON [PRIMARY]
GO
PRINT N'正在向 [dbo].[oxite_Conferences_ScheduleItemCommentRelationship] 添加约束 '
GO
ALTER TABLE [dbo].[oxite_Conferences_ScheduleItemCommentRelationship] ADD CONSTRAINT [IX_oxite_Conferences_ScheduleItemCommentRelationship_Slug_ScheduleItemID] UNIQUE NONCLUSTERED  ([Slug], [ScheduleItemID]) ON [PRIMARY]
GO
PRINT N'正在向 [dbo].[oxite_Comment] 添加外键'
GO
ALTER TABLE [dbo].[oxite_Comment] ADD
CONSTRAINT [FK_oxite_Comment_oxite_Comment] FOREIGN KEY ([ParentCommentID]) REFERENCES [dbo].[oxite_Comment] ([CommentID]),
CONSTRAINT [FK_oxite_Comment_oxite_User] FOREIGN KEY ([CreatorUserID]) REFERENCES [dbo].[oxite_User] ([UserID]),
CONSTRAINT [FK_oxite_Comment_oxite_Language] FOREIGN KEY ([LanguageID]) REFERENCES [dbo].[oxite_Language] ([LanguageID])
GO
PRINT N'正在向 [dbo].[oxite_Blogs_PostFileRelationship] 添加外键'
GO
ALTER TABLE [dbo].[oxite_Blogs_PostFileRelationship] ADD
CONSTRAINT [FK_oxite_Blogs_PostFileRelationship_oxite_Blogs_Post] FOREIGN KEY ([PostID]) REFERENCES [dbo].[oxite_Blogs_Post] ([PostID]),
CONSTRAINT [FK_oxite_Blogs_PostFileRelationship_oxite_File] FOREIGN KEY ([FileID]) REFERENCES [dbo].[oxite_File] ([FileID])
GO
PRINT N'正在向 [dbo].[oxite_Blogs_PostTagRelationship] 添加外键'
GO
ALTER TABLE [dbo].[oxite_Blogs_PostTagRelationship] ADD
CONSTRAINT [FK_oxite_Blogs_PostTagRelationship_oxite_Blogs_Post] FOREIGN KEY ([PostID]) REFERENCES [dbo].[oxite_Blogs_Post] ([PostID]),
CONSTRAINT [FK_oxite_Blogs_PostTagRelationship_oxite_Tag] FOREIGN KEY ([TagID]) REFERENCES [dbo].[oxite_Tag] ([TagID])
GO
PRINT N'正在向 [dbo].[oxite_Blogs_PostSubscriptionRelationship] 添加外键'
GO
ALTER TABLE [dbo].[oxite_Blogs_PostSubscriptionRelationship] ADD
CONSTRAINT [FK_oxite_Blogs_PostSubscriptionRelationship_oxite_Blogs_Post] FOREIGN KEY ([PostID]) REFERENCES [dbo].[oxite_Blogs_Post] ([PostID]),
CONSTRAINT [FK_oxite_Blogs_PostSubscriptionRelationship_oxite_Subscription] FOREIGN KEY ([SubscriptionID]) REFERENCES [dbo].[oxite_Subscription] ([SubscriptionID])
GO
PRINT N'正在向 [dbo].[oxite_ExtendedPropertyScope] 添加外键'
GO
ALTER TABLE [dbo].[oxite_ExtendedPropertyScope] ADD
CONSTRAINT [FK_oxite_ExtendedPropertyScope_oxite_ExtendedProperty] FOREIGN KEY ([ExtendedPropertyID]) REFERENCES [dbo].[oxite_ExtendedProperty] ([ExtendedPropertyID])
GO
PRINT N'正在向 [dbo].[oxite_Conferences_ScheduleItemFlag] 添加外键'
GO
ALTER TABLE [dbo].[oxite_Conferences_ScheduleItemFlag] ADD
CONSTRAINT [FK_oxite_Conferences_ScheduleItemFlag_oxite_Conferences_ScheduleItem] FOREIGN KEY ([ScheduleItemID]) REFERENCES [dbo].[oxite_Conferences_ScheduleItem] ([ScheduleItemID])
GO
PRINT N'正在向 [dbo].[oxite_Conferences_ScheduleItemCommentRelationship] 添加外键'
GO
ALTER TABLE [dbo].[oxite_Conferences_ScheduleItemCommentRelationship] ADD
CONSTRAINT [FK_oxite_Conferences_ScheduleItemCommentRelationship_oxite_Comment] FOREIGN KEY ([CommentID]) REFERENCES [dbo].[oxite_Comment] ([CommentID]),
CONSTRAINT [FK_oxite_Conferences_ScheduleItemCommentRelationship_oxite_Conferences_ScheduleItem] FOREIGN KEY ([ScheduleItemID]) REFERENCES [dbo].[oxite_Conferences_ScheduleItem] ([ScheduleItemID])
GO
PRINT N'正在向 [dbo].[oxite_Blogs_BlogRoleUserRelationship] 添加外键'
GO
ALTER TABLE [dbo].[oxite_Blogs_BlogRoleUserRelationship] ADD
CONSTRAINT [FK_oxite_Blogs_BlogRoleUserRelationship_oxite_Blogs_Blog] FOREIGN KEY ([BlogID]) REFERENCES [dbo].[oxite_Blogs_Blog] ([BlogID]),
CONSTRAINT [FK_oxite_Blogs_BlogRoleUserRelationship_oxite_Role] FOREIGN KEY ([RoleID]) REFERENCES [dbo].[oxite_Role] ([RoleID]),
CONSTRAINT [FK_oxite_Blogs_BlogRoleUserRelationship_oxite_User] FOREIGN KEY ([UserID]) REFERENCES [dbo].[oxite_User] ([UserID])
GO
PRINT N'正在向 [dbo].[oxite_Conferences_ScheduleItemUserRelationship] 添加外键'
GO
ALTER TABLE [dbo].[oxite_Conferences_ScheduleItemUserRelationship] ADD
CONSTRAINT [FK_oxite_Conferences_ScheduleItemUserRelationship_oxite_Conferences_ScheduleItem] FOREIGN KEY ([ScheduleItemID]) REFERENCES [dbo].[oxite_Conferences_ScheduleItem] ([ScheduleItemID])
GO
PRINT N'正在向 [dbo].[oxite_SiteRoleUserRelationship] 添加外键'
GO
ALTER TABLE [dbo].[oxite_SiteRoleUserRelationship] ADD
CONSTRAINT [FK_oxite_SiteRoleUserRelationship_oxite_Role] FOREIGN KEY ([RoleID]) REFERENCES [dbo].[oxite_Role] ([RoleID]),
CONSTRAINT [FK_oxite_SiteRoleUserRelationship_oxite_Site] FOREIGN KEY ([SiteID]) REFERENCES [dbo].[oxite_Site] ([SiteID]),
CONSTRAINT [FK_oxite_SiteRoleUserRelationship_oxite_User] FOREIGN KEY ([UserID]) REFERENCES [dbo].[oxite_User] ([UserID])
GO
PRINT N'正在向 [dbo].[oxite_UserLanguage] 添加外键'
GO
ALTER TABLE [dbo].[oxite_UserLanguage] ADD
CONSTRAINT [FK_oxite_UserLanguage_oxite_Language] FOREIGN KEY ([LanguageID]) REFERENCES [dbo].[oxite_Language] ([LanguageID]),
CONSTRAINT [FK_oxite_UserLanguage_oxite_User] FOREIGN KEY ([UserID]) REFERENCES [dbo].[oxite_User] ([UserID])
GO
PRINT N'正在向 [dbo].[oxite_CMS_PageRoleUserRelationship] 添加外键'
GO
ALTER TABLE [dbo].[oxite_CMS_PageRoleUserRelationship] ADD
CONSTRAINT [FK_oxite_CMS_PageRoleUserRelationship_oxite_CMS_Page] FOREIGN KEY ([PageID]) REFERENCES [dbo].[oxite_CMS_Page] ([PageID]),
CONSTRAINT [FK_oxite_CMS_PageRoleUserRelationship_oxite_Role] FOREIGN KEY ([RoleID]) REFERENCES [dbo].[oxite_Role] ([RoleID]),
CONSTRAINT [FK_oxite_CMS_PageRoleUserRelationship_oxite_User] FOREIGN KEY ([UserID]) REFERENCES [dbo].[oxite_User] ([UserID])
GO
PRINT N'正在向 [dbo].[oxite_StringResourceVersion] 添加外键'
GO
ALTER TABLE [dbo].[oxite_StringResourceVersion] ADD
CONSTRAINT [FK_oxite_StringResourceVersion_oxite_StringResource] FOREIGN KEY ([StringResourceKey]) REFERENCES [dbo].[oxite_StringResource] ([StringResourceKey])
GO
PRINT N'正在向 [dbo].[oxite_Plugin] 添加外键'
GO
ALTER TABLE [dbo].[oxite_Plugin] ADD
CONSTRAINT [FK_oxite_Plugin_oxite_Site] FOREIGN KEY ([SiteID]) REFERENCES [dbo].[oxite_Site] ([SiteID])
GO
PRINT N'正在向 [dbo].[oxite_Blogs_PostView] 添加外键'
GO
ALTER TABLE [dbo].[oxite_Blogs_PostView] ADD
CONSTRAINT [FK_oxite_Blogs_PostView_oxite_Blogs_Post] FOREIGN KEY ([PostID]) REFERENCES [dbo].[oxite_Blogs_Post] ([PostID]),
CONSTRAINT [FK_oxite_Blogs_PostView_oxite_Blogs_PostViewType] FOREIGN KEY ([PostViewTypeID]) REFERENCES [dbo].[oxite_Blogs_PostViewType] ([PostViewTypeID])
GO
PRINT N'正在向 [dbo].[oxite_Conferences_ScheduleTimeSlot] 添加外键'
GO
ALTER TABLE [dbo].[oxite_Conferences_ScheduleTimeSlot] ADD
CONSTRAINT [FK_oxite_Conferences_ScheduleTimeSlot_oxite_Conferences_Event] FOREIGN KEY ([EventID]) REFERENCES [dbo].[oxite_Conferences_Event] ([EventID])
GO
PRINT N'正在向 [dbo].[oxite_User] 添加外键'
GO
ALTER TABLE [dbo].[oxite_User] ADD
CONSTRAINT [FK_oxite_User_oxite_Language] FOREIGN KEY ([DefaultLanguageID]) REFERENCES [dbo].[oxite_Language] ([LanguageID])
GO
PRINT N'正在向 [dbo].[oxite_Conferences_ScheduleItemSpeakerRelationship] 添加外键'
GO
ALTER TABLE [dbo].[oxite_Conferences_ScheduleItemSpeakerRelationship] ADD
CONSTRAINT [FK_oxite_Conferences_ScheduleItemSpeakerRelationship_oxite_Conferences_ScheduleItem] FOREIGN KEY ([ScheduleItemID]) REFERENCES [dbo].[oxite_Conferences_ScheduleItem] ([ScheduleItemID]),
CONSTRAINT [FK_oxite_Conferences_ScheduleItemSpeakerRelationship_oxite_Conferences_Speaker] FOREIGN KEY ([SpeakerID]) REFERENCES [dbo].[oxite_Conferences_Speaker] ([SpeakerID])
GO
PRINT N'正在向 [dbo].[oxite_ExtendedPropertyValue] 添加外键'
GO
ALTER TABLE [dbo].[oxite_ExtendedPropertyValue] ADD
CONSTRAINT [FK_oxite_ExtendedPropertyValue_oxite_ExtendedProperty] FOREIGN KEY ([ExtendedPropertyID]) REFERENCES [dbo].[oxite_ExtendedProperty] ([ExtendedPropertyID]),
CONSTRAINT [FK_oxite_ExtendedPropertyValue_oxite_Site] FOREIGN KEY ([SiteID]) REFERENCES [dbo].[oxite_Site] ([SiteID])
GO
PRINT N'正在向 [dbo].[oxite_Conferences_ScheduleItemSubscriptionRelationship] 添加外键'
GO
ALTER TABLE [dbo].[oxite_Conferences_ScheduleItemSubscriptionRelationship] ADD
CONSTRAINT [FK_oxite_Conferences_ScheduleItemSubscriptionRelationship_oxite_Conferences_ScheduleItem] FOREIGN KEY ([ScheduleItemID]) REFERENCES [dbo].[oxite_Conferences_ScheduleItem] ([ScheduleItemID]),
CONSTRAINT [FK_oxite_Conferences_ScheduleItemSubscriptionRelationship_oxite_Subscription] FOREIGN KEY ([SubscriptionID]) REFERENCES [dbo].[oxite_Subscription] ([SubscriptionID])
GO
PRINT N'正在向 [dbo].[oxite_Blogs_Trackback] 添加外键'
GO
ALTER TABLE [dbo].[oxite_Blogs_Trackback] ADD
CONSTRAINT [FK_oxite_Blogs_Trackback_oxite_Blogs_Post] FOREIGN KEY ([PostID]) REFERENCES [dbo].[oxite_Blogs_Post] ([PostID])
GO
PRINT N'正在向 [dbo].[oxite_Subscription] 添加外键'
GO
ALTER TABLE [dbo].[oxite_Subscription] ADD
CONSTRAINT [FK_oxite_Subscription_oxite_User] FOREIGN KEY ([UserID]) REFERENCES [dbo].[oxite_User] ([UserID])
GO
PRINT N'正在向 [dbo].[oxite_CMS_Page] 添加外键'
GO
ALTER TABLE [dbo].[oxite_CMS_Page] ADD
CONSTRAINT [FK_oxite_CMS_Page_oxite_Site] FOREIGN KEY ([SiteID]) REFERENCES [dbo].[oxite_Site] ([SiteID])
GO
PRINT N'正在向 [dbo].[oxite_Conferences_ScheduleItemTagRelationship] 添加外键'
GO
ALTER TABLE [dbo].[oxite_Conferences_ScheduleItemTagRelationship] ADD
CONSTRAINT [FK_oxite_Conferences_ScheduleItemTagRelationship_oxite_Conferences_ScheduleItem] FOREIGN KEY ([ScheduleItemID]) REFERENCES [dbo].[oxite_Conferences_ScheduleItem] ([ScheduleItemID]),
CONSTRAINT [FK_oxite_Conferences_ScheduleItemTagRelationship_oxite_Tag] FOREIGN KEY ([TagID]) REFERENCES [dbo].[oxite_Tag] ([TagID])
GO
PRINT N'正在向 [dbo].[oxite_CMS_PageContentItemRelationship] 添加外键'
GO
ALTER TABLE [dbo].[oxite_CMS_PageContentItemRelationship] ADD
CONSTRAINT [FK_oxite_CMS_PageContentItemRelationship_oxite_CMS_ContentItem] FOREIGN KEY ([ContentItemID]) REFERENCES [dbo].[oxite_CMS_ContentItem] ([ContentItemID]),
CONSTRAINT [FK_oxite_CMS_PageContentItemRelationship_oxite_CMS_Page] FOREIGN KEY ([PageID]) REFERENCES [dbo].[oxite_CMS_Page] ([PageID])
GO
PRINT N'正在向 [dbo].[oxite_Blogs_PostCommentRelationship] 添加外键'
GO
ALTER TABLE [dbo].[oxite_Blogs_PostCommentRelationship] ADD
CONSTRAINT [FK_oxite_Blogs_PostCommentRelationship_oxite_Blogs_Post] FOREIGN KEY ([PostID]) REFERENCES [dbo].[oxite_Blogs_Post] ([PostID]),
CONSTRAINT [FK_oxite_Blogs_PostCommentRelationship_oxite_Comment] FOREIGN KEY ([CommentID]) REFERENCES [dbo].[oxite_Comment] ([CommentID])
GO
PRINT N'正在向 [dbo].[oxite_Conferences_ScheduleItemFileRelationship] 添加外键'
GO
ALTER TABLE [dbo].[oxite_Conferences_ScheduleItemFileRelationship] ADD
CONSTRAINT [FK_oxite_Conferences_ScheduleItemFileRelationship_oxite_Conferences_ScheduleItem] FOREIGN KEY ([ScheduleItemID]) REFERENCES [dbo].[oxite_Conferences_ScheduleItem] ([ScheduleItemID])
GO
PRINT N'正在向 [dbo].[oxite_PluginSequence] 添加外键'
GO
ALTER TABLE [dbo].[oxite_PluginSequence] ADD
CONSTRAINT [FK_oxite_PluginSequence_oxite_Plugin] FOREIGN KEY ([PluginID]) REFERENCES [dbo].[oxite_Plugin] ([PluginID])
GO
PRINT N'正在向 [dbo].[oxite_Tag] 添加外键'
GO
ALTER TABLE [dbo].[oxite_Tag] ADD
CONSTRAINT [FK_oxite_Tag_oxite_Tag] FOREIGN KEY ([ParentTagID]) REFERENCES [dbo].[oxite_Tag] ([TagID])
GO
PRINT N'正在向 [dbo].[oxite_Role] 添加外键'
GO
ALTER TABLE [dbo].[oxite_Role] ADD
CONSTRAINT [FK_oxite_Role_oxite_Role] FOREIGN KEY ([GroupRoleID]) REFERENCES [dbo].[oxite_Role] ([RoleID])
GO
PRINT N'正在向 [dbo].[oxite_UserModuleData] 添加外键'
GO
ALTER TABLE [dbo].[oxite_UserModuleData] ADD
CONSTRAINT [FK_oxite_UserModuleData_oxite_User] FOREIGN KEY ([UserID]) REFERENCES [dbo].[oxite_User] ([UserID])
GO
PRINT N'正在向 [dbo].[oxite_Conferences_ScheduleItem] 添加外键'
GO
ALTER TABLE [dbo].[oxite_Conferences_ScheduleItem] ADD
CONSTRAINT [FK_oxite_Conferences_ScheduleItem_oxite_Conferences_Event] FOREIGN KEY ([EventID]) REFERENCES [dbo].[oxite_Conferences_Event] ([EventID])
GO
PRINT N'正在向 [dbo].[oxite_CMS_ContentItem] 添加外键'
GO
ALTER TABLE [dbo].[oxite_CMS_ContentItem] ADD
CONSTRAINT [FK_oxite_CMS_ContentItem_oxite_CMS_Page] FOREIGN KEY ([PageID]) REFERENCES [dbo].[oxite_CMS_Page] ([PageID]),
CONSTRAINT [FK_oxite_CMS_ContentItem_oxite_User] FOREIGN KEY ([CreatorUserID]) REFERENCES [dbo].[oxite_User] ([UserID])
GO
PRINT N'正在向 [dbo].[oxite_Blogs_Blog] 添加外键'
GO
ALTER TABLE [dbo].[oxite_Blogs_Blog] ADD
CONSTRAINT [FK_oxite_Blogs_Blog_oxite_Site] FOREIGN KEY ([SiteID]) REFERENCES [dbo].[oxite_Site] ([SiteID])
GO
PRINT N'正在向 [dbo].[oxite_SiteRedirect] 添加外键'
GO
ALTER TABLE [dbo].[oxite_SiteRedirect] ADD
CONSTRAINT [FK_oxite_SiteRedirect_oxite_Site] FOREIGN KEY ([SiteID]) REFERENCES [dbo].[oxite_Site] ([SiteID])
GO
PRINT N'正在向 [dbo].[oxite_Blogs_Post] 添加外键'
GO
ALTER TABLE [dbo].[oxite_Blogs_Post] ADD
CONSTRAINT [FK_oxite_Blogs_Post_oxite_Blogs_Blog] FOREIGN KEY ([BlogID]) REFERENCES [dbo].[oxite_Blogs_Blog] ([BlogID]),
CONSTRAINT [FK_oxite_Blogs_Post_oxite_User] FOREIGN KEY ([CreatorUserID]) REFERENCES [dbo].[oxite_User] ([UserID])
GO
PRINT N'正在向 [dbo].[oxite_Blogs_PostRoleUserRelationship] 添加外键'
GO
ALTER TABLE [dbo].[oxite_Blogs_PostRoleUserRelationship] ADD
CONSTRAINT [FK_oxite_Blogs_PostRoleUserRelationship_oxite_Blogs_Post] FOREIGN KEY ([PostID]) REFERENCES [dbo].[oxite_Blogs_Post] ([PostID]),
CONSTRAINT [FK_oxite_Blogs_PostRoleUserRelationship_oxite_Role] FOREIGN KEY ([RoleID]) REFERENCES [dbo].[oxite_Role] ([RoleID]),
CONSTRAINT [FK_oxite_Blogs_PostRoleUserRelationship_oxite_User] FOREIGN KEY ([UserID]) REFERENCES [dbo].[oxite_User] ([UserID])
GO

GO
/*
Post-Deployment Script Template							
--------------------------------------------------------------------------------------
 This file contains SQL statements that will be appended to the build script		
 Use SQLCMD syntax to include a file into the post-deployment script			
 Example:      :r .\filename.sql								
 Use SQLCMD syntax to reference a variable in the post-deployment script		
 Example:      :setvar TableName MyTable							
               SELECT * FROM [$(TableName)]					
--------------------------------------------------------------------------------------
*/








DECLARE @SiteID uniqueidentifier
SET @SiteID = '4F36436B-0782-4a94-BB4C-FD3916734C03'

IF NOT EXISTS(SELECT * FROM oxite_Site WHERE SiteHost = 'http://localhost:30913')
BEGIN
	INSERT INTO
		oxite_Site
	(
		SiteID,
		SiteHost,
		SiteName,
		SiteDisplayName,
		SiteDescription,
		LanguageDefault,
		TimeZoneOffset,
		PageTitleSeparator,
		FavIconUrl,
		CommentStateDefault,
		IncludeOpenSearch,
		AuthorAutoSubscribe,
		PostEditTimeout,
		GravatarDefault,
		SkinsPath,
		SkinsScriptsPath,
		SkinsStylesPath,
		Skin,
		AdminSkin,
		ServiceRetryCountDefault,
		HasMultipleBlogs,
		RouteUrlPrefix,
		CommentingDisabled,
		PluginsPath
	)
	VALUES
	(
		@SiteID,
		'http://localhost:30913',
		'Oxite',
		'Oxite Sample',
		'This is the Oxite Sample description',
		'en',
		-8,
		' - ',
		'/Content/icons/flame.ico',
		'Normal',
		1,
		1,
		24,
		'http://mschnlnine.vo.llnwd.net/d1/oxite/gravatar.jpg',
		'/Skins',
		'/Scripts',
		'/Styles',
		'',
		'Admin',
		10,
		0,
		'',
		0,
		'/Plugins'
	)
END
GO


DECLARE @LanguageID uniqueidentifier
SET @LanguageID = '2E0FDFBD-99DD-4970-BAED-2B9653672FC1'

IF NOT EXISTS(SELECT * FROM oxite_Language WHERE LanguageID = @LanguageID)
	INSERT INTO
		oxite_Language
	(
		LanguageID,
		LanguageName,
		LanguageDisplayName
	)
	VALUES
	(
		@LanguageID,
		'en',
		'English'
	)

SET @LanguageID = '73744873-B73A-4a2e-A9EB-D496452E5899'

IF NOT EXISTS(SELECT * FROM oxite_Language WHERE LanguageID = @LanguageID)
	INSERT INTO
		oxite_Language
	(
		LanguageID,
		LanguageName,
		LanguageDisplayName
	)
	VALUES
	(
		@LanguageID,
		'af',
		'Afrikaans'
	)
	
SET @LanguageID = 'A3CDD27F-13CF-40e5-ABD1-0AC461D92C90'

IF NOT EXISTS(SELECT * FROM oxite_Language WHERE LanguageID = @LanguageID)
	INSERT INTO
		oxite_Language
	(
		LanguageID,
		LanguageName,
		LanguageDisplayName
	)
	VALUES
	(
		@LanguageID,
		'sq',
		'Albanian'
	)
	
SET @LanguageID = 'D776FB0D-F80C-42a4-BD17-7F527D637931'

IF NOT EXISTS(SELECT * FROM oxite_Language WHERE LanguageID = @LanguageID)
	INSERT INTO
		oxite_Language
	(
		LanguageID,
		LanguageName,
		LanguageDisplayName
	)
	VALUES
	(
		@LanguageID,
		'gsw',
		'Alsatian'
	)

SET @LanguageID = 'D7555824-06A8-4092-B3F8-4C7704C79BF7'

IF NOT EXISTS(SELECT * FROM oxite_Language WHERE LanguageID = @LanguageID)
	INSERT INTO
		oxite_Language
	(
		LanguageID,
		LanguageName,
		LanguageDisplayName
	)
	VALUES
	(
		@LanguageID,
		'am',
		'Amharic'
	)
	
SET @LanguageID = '81C0BF33-4BFF-4fcc-9470-17770084656A'

IF NOT EXISTS(SELECT * FROM oxite_Language WHERE LanguageID = @LanguageID)
	INSERT INTO
		oxite_Language
	(
		LanguageID,
		LanguageName,
		LanguageDisplayName
	)
	VALUES
	(
		@LanguageID,
		'ar',
		'Arabic'
	)
	
SET @LanguageID = 'E75FAF5A-90A6-4ef6-A832-6D13CAF7A613'

IF NOT EXISTS(SELECT * FROM oxite_Language WHERE LanguageID = @LanguageID)
	INSERT INTO
		oxite_Language
	(
		LanguageID,
		LanguageName,
		LanguageDisplayName
	)
	VALUES
	(
		@LanguageID,
		'hy',
		'Armenian'
	)
	
SET @LanguageID = '57666CD3-8718-4434-B3CE-E035BC00FA2F'

IF NOT EXISTS(SELECT * FROM oxite_Language WHERE LanguageID = @LanguageID)
	INSERT INTO
		oxite_Language
	(
		LanguageID,
		LanguageName,
		LanguageDisplayName
	)
	VALUES
	(
		@LanguageID,
		'as',
		'Assamese'
	)
	
SET @LanguageID = '4473077D-F5D9-4ff1-B147-641B8107950C'

IF NOT EXISTS(SELECT * FROM oxite_Language WHERE LanguageID = @LanguageID)
	INSERT INTO
		oxite_Language
	(
		LanguageID,
		LanguageName,
		LanguageDisplayName
	)
	VALUES
	(
		@LanguageID,
		'az',
		'Azeri'
	)
	
SET @LanguageID = 'DE5F9E9B-73F1-4cad-9CD1-B07667904145'

IF NOT EXISTS(SELECT * FROM oxite_Language WHERE LanguageID = @LanguageID)
	INSERT INTO
		oxite_Language
	(
		LanguageID,
		LanguageName,
		LanguageDisplayName
	)
	VALUES
	(
		@LanguageID,
		'ba',
		'Bashkir'
	)
	
--SET @LanguageID = ''

--IF NOT EXISTS(SELECT * FROM oxite_Language WHERE LanguageID = @LanguageID)
	--INSERT INTO
		--oxite_Language
	--(
		--LanguageID,
		--LanguageName,
		--LanguageDisplayName
	--)
	--VALUES
	--(
		--@LanguageID,
		--'',
		--''
	--)
GO


DECLARE @LanguageID uniqueidentifier
SET @LanguageID = '2E0FDFBD-99DD-4970-BAED-2B9653672FC1' --English

DECLARE @User1ID uniqueidentifier
SET @User1ID = '655D3498-03DB-4075-A80E-6514EC6BB6E2'

IF NOT EXISTS(SELECT * FROM oxite_User WHERE UserID = @User1ID)
BEGIN
	INSERT INTO
		oxite_User
	(
		UserID,
		Username,
		DisplayName,
		Email,
		HashedEmail,
		DefaultLanguageID,
		Status
	)
	VALUES
	(
		@User1ID,
		'Admin',
		'Oxite Administrator',
		'',
		'8d33d9c3c448f2c14d722900c2bd6098',
		@LanguageID,
		1
	)
	
	INSERT INTO
		oxite_UserModuleData
	(
		UserID,
		ModuleName,
		Data
	)
	VALUES
	(
		@User1ID,
		'FormsAuthentication',
		'NaCl|BQWPtrSvaXLSzkU6vOM4XeV/080hsgtsVIjLEPFny7k='
	)
END

DECLARE @User2ID uniqueidentifier
SET @User2ID = 'C0981693-799A-4331-B2DD-C83084538669'

IF NOT EXISTS(SELECT * FROM oxite_User WHERE UserID = @User2ID)
	INSERT INTO
		oxite_User
	(
		UserID,
		Username,
		DisplayName,
		Email,
		HashedEmail,
		DefaultLanguageID,
		Status
	)
	VALUES
	(
		@User2ID,
		'Anonymous',
		'',
		'',
		'',
		@LanguageID,
		1
	)

--UserLanguages
IF NOT EXISTS(SELECT * FROM oxite_UserLanguage WHERE UserID = @User1ID AND LanguageID = @LanguageID)
	INSERT INTO
		oxite_UserLanguage
	(
		UserID,
		LanguageID
	)
	VALUES
	(
		@User1ID,
		@LanguageID
	)

IF NOT EXISTS(SELECT * FROM oxite_UserLanguage WHERE UserID = @User2ID AND LanguageID = @LanguageID)
	INSERT INTO
		oxite_UserLanguage
	(
		UserID,
		LanguageID
	)
	VALUES
	(
		@User2ID,
		@LanguageID
	)
GO


IF NOT EXISTS(SELECT * FROM oxite_Blogs_PostViewType WHERE PostViewTypeName = 'Post-Web')
BEGIN
	INSERT INTO
		oxite_Blogs_PostViewType
	(
		PostViewTypeID,
		PostViewTypeName
	)
	VALUES
	(
		'A38FD696-22E2-4612-A392-E73FCAABB61D',
		'Post-Web'
	)
END

IF NOT EXISTS(SELECT * FROM oxite_Blogs_PostViewType WHERE PostViewTypeName = 'Post-RSS')
BEGIN
	INSERT INTO
		oxite_Blogs_PostViewType
	(
		PostViewTypeID,
		PostViewTypeName
	)
	VALUES
	(
		'6A945758-48C3-4e43-A1E3-AED601F5F022',
		'Post-RSS'
	)
END

IF NOT EXISTS(SELECT * FROM oxite_Blogs_PostViewType WHERE PostViewTypeName = 'Post-ATOM')
BEGIN
	INSERT INTO
		oxite_Blogs_PostViewType
	(
		PostViewTypeID,
		PostViewTypeName
	)
	VALUES
	(
		'E3080032-0203-42c4-8B36-76A8168FB474',
		'Post-ATOM'
	)
END
GO


DECLARE @BlogID uniqueidentifier
SET @BlogID = '66F2AF76-8F03-4621-8114-CAA137AFF185'
DECLARE @SiteID uniqueidentifier
SET @SiteID = '4F36436B-0782-4a94-BB4C-FD3916734C03'

IF NOT EXISTS(SELECT * FROM oxite_Blogs_Blog WHERE BlogID = @BlogID)
	INSERT INTO
		oxite_Blogs_Blog
	(
		SiteID,
		BlogID,
		BlogName,
		DisplayName,
		Description,
		CommentingDisabled,
		CreatedDate,
		ModifiedDate
	)
	VALUES
	(
		@SiteID,
		@BlogID,
		'Blog',
		'Oxite Sample',
		'This is the Oxite Sample description',
		0,
		getUtcDate(),
		getUtcDate()
	)
GO


DECLARE @SiteID uniqueidentifier
SET @SiteID = '4F36436B-0782-4a94-BB4C-FD3916734C03'
DECLARE @BlogID uniqueidentifier
SET @BlogID = '66F2AF76-8F03-4621-8114-CAA137AFF185'
DECLARE @PostID uniqueidentifier
SET @PostID = 'C5FA9D2A-24B2-45e2-955A-92E88A34260C'
DECLARE @User1ID uniqueidentifier
SET @User1ID = '655D3498-03DB-4075-A80E-6514EC6BB6E2'

IF NOT EXISTS(SELECT * FROM oxite_Blogs_Post WHERE PostID = @PostID)
	INSERT INTO oxite_Blogs_Post (BlogID, PostID, CreatorUserID, Title, Body, BodyShort, State, Slug, CommentingDisabled, CreatedDate, ModifiedDate, PublishedDate) VALUES
	(
		@BlogID,
		@PostID,
		@User1ID,
		'World.Hello()',
		'<p>Welcome to Oxite! This is a sample application targeting developers built on <a href="http://asp.net/mvc">ASP.NET MVC</a>. Make any changes you like. If you build a feature you think other developers would be interested in and would like to share your code go to the <a href="http://www.codeplex.com/oxite">Oxite Code Plex project</a> to see how you can contribute.</p><p>To get started, sign in with "Admin" and "pa$$w0rd" and click on the Admin tab.</p><p>For more information about <a href="http://oxite.net">Oxite</a> visit the default <a href="/About">About</a> page.</p>',
		'<p>Welcome to Oxite! This is a sample application targeting developers built on <a href="http://asp.net/mvc">ASP.NET MVC</a>. Make any changes you like. If you build a feature you think other developers would be interested in and would like to share your code go to the <a href="http://www.codeplex.com/oxite">Oxite Code Plex project</a> to see how you can contribute.</p><p>To get started, sign in with "Admin" and "pa$$w0rd" and click on the Admin tab.</p><p>For more information about <a href="http://oxite.net">Oxite</a> visit the default <a href="/About">About</a> page.</p>',
		1,
		'Hello-World',
		0,
		getUtcDate(),
		getUtcDate(),
		getUtcDate()
	)

DECLARE @TagID uniqueidentifier
SET @TagID = newid()

IF NOT EXISTS(SELECT * FROM oxite_Tag WHERE TagID = @TagID)
	INSERT INTO
		oxite_Tag
	(
		ParentTagID,
		TagID,
		TagName,
		CreatedDate
	)
	VALUES
	(
		@TagID,
		@TagID,
		'Oxite',
		getUtcDate()
	)

IF NOT EXISTS(SELECT * FROM oxite_Blogs_PostTagRelationship WHERE TagID = @TagID AND PostID = @PostID)
	INSERT INTO
		oxite_Blogs_PostTagRelationship
	(
		TagID,
		PostID
	)
	VALUES
	(
		@TagID,
		@PostID
	)

GO


DECLARE @SiteID uniqueidentifier
SET @SiteID = '4F36436B-0782-4a94-BB4C-FD3916734C03'
DECLARE @User1ID uniqueidentifier
SET @User1ID = '655D3498-03DB-4075-A80E-6514EC6BB6E2'
DECLARE @PageID uniqueidentifier, @ContentItemID uniqueidentifier
SET @PageID = 'D2D69195-F49A-4f68-AA3C-D7B4CF69F695'
SET @ContentItemID = '3B6322C8-59AB-46ee-8A10-68A8513DEAD5'

IF NOT EXISTS(SELECT * FROM oxite_CMS_Page WHERE PageID = @PageID)
BEGIN
	INSERT INTO oxite_CMS_Page
	(
		SiteID,
		PageID,
		TemplateName,
		Title,
		Description,
		Slug,
		PublishedDate
	)
	VALUES
	(
		@SiteID,
		@PageID,
		'',
		'About',
		'Sample about page for Oxite',
		'About',
		getUtcDate()
	)

	INSERT INTO
		oxite_CMS_ContentItem
	(
		SiteID,
		PageID,
		ContentItemID,
		ContentItemName,
		ContentItemDisplayName,
		Body,
		Version,
		CreatorUserID,
		CreatedDate,
		PublishedDate
	)
	VALUES
	(
		@SiteID,
		@PageID,
		@ContentItemID,
		'Content',
		'About',
		'<p>Welcome to the Oxite Sample! Since this is a sample, we thought we would use this handy about page to explain a few things about the code and about the thoughts that went into its creation.</p>
<h3>What is this?</h3>    
<p>This is a simple blog engine written using <a href="http://asp.net/mvc">ASP.NET MVC</a>, and is designed with two main goals:</p>
<ol class="normal">
	<li>To provide a sample of ''core blog functionality'' in a reusable fashion. &nbsp;Blogs are simple and well understood by many developers, but the set of basic functions that a blog needs to implement (trackbacks, rss, comments, etc.) are fairly complex.  Hopefully this code helps.</li>
	<li>To provide a real-world sample written using <a href="http://asp.net/mvc">ASP.NET MVC</a>.</li>
</ol>
<p>We aren''t a sample-building team (more on what we are in a bit). &nbsp;We couldn''t sit down and build this code base just to give out to folks, so this code is also the foundation of a real project of ours, <a href="http://visitmix.com">MIX Online</a>. &nbsp;We also created this project to be the base of our own personal blogs as well; check out <a href="http://www.codeplex.com/oxite/Wiki/View.aspx?title=oxitesites&amp;referringTitle=Home">this page on CodePlex to see a list of sites that use Oxite</a> (and use the comments area to tell us about your site).</p>
<h3>What this isn''t</h3>
<p>This is not an ''off the shelf'' blogging package. &nbsp;If you aren''t a developer and just want to get blogging then you should look at one of these great blogging products: <a href="http://graffiticms.com/">Graffiti</a>, <a href="http://subtextproject.com/">SubText</a>, <a href="http://www.dotnetblogengine.net/">Blog Engine .NET</a>, <a href="http://dasblog.info/">dasBlog</a> or a hosted service like <a href="http://wordpress.com/">Wordpress</a></p>
<p>Oxite is also not ready to be an enterprise blogging solution (for you and a thousand other bloggers at your company), although we did design it to be capable of hosting multiple blogs. &nbsp;For that type of solution, a set of provisioning tools to create new blogs would need to be added. &nbsp;Oxite is code though, so you can extend it and customize it to support whatever you need.</p>
<h3>Where to go from here (expanding on this sample)</h3>
<p>You can extend Oxite in whatever way you need or wish, but if you are looking for some ideas here are a few thoughts we''ve already had around new functionality:</p>
<ul>
	<li>Adding a rich-text-editor for post and page editing. &nbsp;We use <a href="http://writer.live.com">Windows Live Writer</a> to post and edit our blog posts, so this isn''t a real issue for our day to day use of the site, but adding an editor like <a href="http://developer.yahoo.com/yui/editor/">http://developer.yahoo.com/yui/editor/</a> would be great.</li>
	<li>Adding UI for managing the creation of new blogs, setting up users and user permissions, etc. &nbsp;If you decided to use Oxite to host many blogs together on one site, or to use the same Oxite database to run many sites (yes, it can do both of those!) then it would be nice to have some UI for managing all those contributors.</li>
	<li>And whatever great idea you have!</li>
</ul>
<h3>Getting the code, reporting bugs, and contributing to this project</h3>
<p><a href="http://codeplex.com/Oxite">Oxite is hosted on CodePlex</a>, so you can grab the latest code from there (you can <a href="http://www.codeplex.com/oxite/SourceControl/ListDownloadableCommits.aspx">see all of our check-ins</a> and also <a href="http://www.codeplex.com/oxite/Release/ProjectReleases.aspx">specific releases</a> when we feel like significant changes have been made), read discussions, file bugs and even submit suggestions for changes. &nbsp;If you''ve made some code changes that you feel should make it back into the Oxite code, then CodePlex is the place to tell us about it!</p>
<h3>About us</h3>
<p>Oxite is a project built by the team behind <a href="http://channel9.msdn.com/">Channel 9</a> (and <a href="http://channel8.msdn.com/">Channel 8</a>, <a href="http://on10.net/">Channel 10</a>, <a href="http://edge.technet.com/">TechNet Edge</a>, <a href="http://visitmix.com/">Mix Online</a>): Erik Porter, Nathan Heskew, Mike Sampson and Duncan Mackenzie. &nbsp;You can find out more about our team and our projects in our <a href="http://channel9.msdn.com/tags/evnet/">various posts and videos on Channel 9</a>.</p>
<p><a href="http://validator.w3.org/check?uri=referer"><img src="/Content/images/valid-xhtml10-blue.png" alt="Valid XHTML 1.0 Strict" height="31" width="88" /></a> <a href="http://jigsaw.w3.org/css-validator/"><img style="border:0;width:88px;height:31px" src="/Content/images/vcss-blue.gif" alt="Valid CSS!" /></a> <a href="http://validator.w3.org/feed/check.cgi"><img src="/Content/images/valid-rss.png" alt="[Valid RSS]" title="Validate my RSS feed" /></a></p>',
		1,
		@User1ID,
		getUtcDate(),
		getUtcDate()
	)
END
GO


DECLARE @Role1ID uniqueidentifier
SET @Role1ID = '10C0B1FD-F284-4a7d-BBE0-38A671E2BD34'

IF NOT EXISTS(SELECT * FROM oxite_Role WHERE RoleName = 'Admin')
	INSERT INTO
		oxite_Role
	(
		GroupRoleID,
		RoleID,
		RoleName,
		RoleType
	)
	VALUES
	(
		@Role1ID,
		@Role1ID,
		'Admin',
		15
	)
GO


DECLARE @SiteID uniqueidentifier
SET @SiteID = '4F36436B-0782-4a94-BB4C-FD3916734C03'
DECLARE @Role1ID uniqueidentifier
SET @Role1ID = '10C0B1FD-F284-4a7d-BBE0-38A671E2BD34'

DECLARE @User1ID uniqueidentifier
SET @User1ID = '655D3498-03DB-4075-A80E-6514EC6BB6E2'
IF NOT EXISTS(SELECT * FROM oxite_SiteRoleUserRelationship WHERE SiteID = @SiteID AND RoleID = @Role1ID AND UserID = @User1ID)
	INSERT INTO
		oxite_SiteRoleUserRelationship
	(
		SiteID,
		RoleID,
		UserID
	)
	VALUES
	(
		@SiteID,
		@Role1ID,
		@User1ID
	)
GO



USE [$(DatabaseName)]
IF ((SELECT COUNT(*) 
	FROM 
		::fn_listextendedproperty( 'microsoft_database_tools_deploystamp', null, null, null, null, null, null )) 
	> 0)
BEGIN
	EXEC [dbo].sp_dropextendedproperty 'microsoft_database_tools_deploystamp'
END
EXEC [dbo].sp_addextendedproperty 'microsoft_database_tools_deploystamp', N'13474e0c-0e45-476c-a5e6-38e0f8b35de2'
GO

